package demo1;

import java.io.FileNotFoundException;
import java.nio.channels.FileLockInterruptionException;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Tect {
    public static void main(String[] args) {
        try(Scanner scanner = new Scanner(System.in)){
            int a = scanner.nextInt();
            System.out.println(a);
        }catch(InputMismatchException e){
            System.out.println("找到了InputMismatchException异常，正在修改中....");
            e.printStackTrace();
        }finally {
            System.out.println("finally 执行了");
        }

    }
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try{
            int a =  scanner.nextInt();
            System.out.println(a);
        }catch(InputMismatchException e){
            System.out.println("找到InputMismatchException异常  正在修改....");
            e.printStackTrace();
        }finally {
            System.out.println("finally 执行了...");
            scanner.close();
        }
    }
    public static void func2() throws FileNotFoundException{
        int a = 1;
        if(a == 10){
            throw new NullPointerException();
        }
        if(a == 1){
            throw new FileNotFoundException("文件错误");
        }
    }
    public static void main2(String[] args) {
        try{
            func2();
        }catch(FileNotFoundException e){
            System.out.println("找到了FileLockInterruptionException这个异常，正在修改异常");
            e.printStackTrace();
        }catch(NullPointerException e){
            System.out.println("找到了NullPointerException这个异常，正在修改异常");
        }finally {
            System.out.println("finally 被执行了");
        }
        System.out.println("修改完成,执行下一步代码....");
    }
    public static void func1() throws CloneNotSupportedException {
        int[] array = {1,2,3,4,5};
        if(array == null){
            throw new NullPointerException();

        }
        if(array[1] == 2){
            throw new  CloneNotSupportedException();
        }
        System.out.println("hhhhhhh");
    }
    public static void main1(String[] args) throws  CloneNotSupportedException {
        try {
            func1();
        }catch ( CloneNotSupportedException e){
            System.out.println("找到了CloneNotSupportedException 异常，正在修改异常...");
        }
        System.out.println("已修改完成....");
    }
}
